//
//  OrganDetailSingleViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/27.
//

#import "OrganDetailSingleViewController.h"
#import "OrganDetailInfoViewController.h"
#import "OrganChartViewController.h"
@interface OrganDetailSingleViewController ()

@end

@implementation OrganDetailSingleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isHideNavigationBar = YES;
    self.view.backgroundColor = BACKGROUNDCOLOR;
}

- (void)initSubviews {
    [super initSubviews];
 
    UIView *backView = [UIView new];
    backView.frame = CGRectMake(0, 0, kScreenWidth, 230);
    [backView az_setGradientBackgroundWithColors:@[HexColor(@"#1BBFB2"),HexColor(@"#1BBFB2"),BACKGROUNDCOLOR] locations:@[@0.0,@0.7,@1.0] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1.0)];
    [self.view addSubview:backView];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:UIImageMake(@"icon_arrow_left_white") forState:UIControlStateNormal];
    backBtn.frame = CGRectMake(15, StatusBarHeightConstant, 40, 40);
    backBtn.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backBtn];
    
    
    MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    root.myHorzMargin = 0;
    root.myTop = 25 + NavigationContentTop;
    root.padding = UIEdgeInsetsMake(0, 15, 0, 15);
    root.subviewVSpace = 15;
    [self.view addSubview:root];
    
    MyLinearLayout *top = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    top.myHorzMargin = 0;
    top.gravity = MyGravity_Vert_Center;
    top.myHeight = 35;
    top.subviewHSpace = 10;
    [root addSubview:top];
    
    {
        UILabel *title = [UILabel createLabelText:@"大脑" font:UIFontMake(24) textColor:COLOR_4];
        title.mySize = kAutoSize;
        [top addSubview:title];
        
        UILabel *content = [UILabel createLabelText:@"cerebrum" font:UIFontMake(14) textColor:[COLOR_4 colorWithAlphaComponent:0.5]];
        content.mySize = kAutoSize;
        [top addSubview:content];
    }
    
    MyLinearLayout *middle = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    middle.myHorzMargin = 0;
    middle.myHeight = kAutoHeight;
    middle.padding = UIEdgeInsetsMake(10, 15, 10, 15);
    middle.backgroundColor = COLOR_4;
    middle.layer.cornerRadius = 10;
    [root addSubview:middle];
    
    {
        MyLinearLayout *titleLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        titleLay.myHorzMargin = 0;
        titleLay.gravity = MyGravity_Vert_Center | MyGravity_Horz_Around;
        titleLay.myHeight = kAutoHeight;
        [middle addSubview:titleLay];
        
        NSArray *arrayTitle = @[@"新生",@"极佳",@"正常",@"注意",@"失常",@"混乱"];
        for (int i = 0; i < arrayTitle.count; i++) {
            UILabel *content = [UILabel createLabelText:arrayTitle[i] font:UIFontMake(12) textColor:HexColor(@"#454545")];
            content.mySize = kAutoSize;
            [titleLay addSubview:content];
        }
        
        MyLinearLayout *colorLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        colorLay.myHorzMargin = 0;
        colorLay.gravity = MyGravity_Vert_Center | MyGravity_Horz_Around;
        colorLay.myHeight = 20;
        colorLay.myTop = 5;
        colorLay.layer.cornerRadius = 10;
        [colorLay az_setGradientBackgroundWithColors:@[HexColor(@"#F9B300"),HexColor(@"#FF5A36"),HexColor(@"#EB2F2F"),HexColor(@"#850000")] locations:@[@(0), @(0.6f), @(0.8f), @(1.0f)] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5)];
        [middle addSubview:colorLay];
        
        NSArray *arrayColor = @[@"1",@"2",@"3",@"4",@"5",@"6"];
        for (int i = 0; i < arrayTitle.count; i++) {
            UILabel *content = [UILabel createLabelText:arrayColor[i] font:UIFontMake(12) textColor:COLOR_4];
            content.mySize = kAutoSize;
            [colorLay addSubview:content];
        }
        
        MyLinearLayout *topLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        topLay.myHorzMargin = 10;
        topLay.gravity = MyGravity_Vert_Center;
        topLay.myHeight = kAutoHeight;
        topLay.myTop = 22;
        topLay.subviewHSpace = 20;
        [middle addSubview:topLay];
        
        NSArray *arrayTopLay = @[@"序号",@"器官名称",@"上次",@"此次",@"进退"];
        for (int i = 0; i < arrayTopLay.count; i++) {
            UILabel *content = [UILabel createLabelText:arrayTopLay[i] font:UIFontMake(13) textColor:HexColor(@"#888888")];
            content.mySize = kAutoSize;
            if(i == 1) content.weight = 1;
            [topLay addSubview:content];
        }
        
        NSArray *contentArr = @[@"额叶区",@"顶叶区",@"枕叶区",@"颞叶区",@"小脑",@"脑干"];
        for (int i = 0; i < contentArr.count; i++) {
            
            MyLinearLayout *contentLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
            contentLay.myHorzMargin = 0;
            contentLay.gravity = MyGravity_Vert_Center;
            contentLay.myHeight = 40;
            contentLay.myTop = i==0?10:0;
            contentLay.subviewHSpace = 25 ;
            contentLay.backgroundColor = i%2 == 0 ?BACKGROUNDCOLOR:COLOR_4;
            contentLay.padding = UIEdgeInsetsMake(0, 15, 0, 10);
            contentLay.layer.cornerRadius = 5;
            [middle addSubview:contentLay];
            
            UILabel *xuhao = [UILabel createLabelText:[@(i+1) stringValue] font:UIFontMake(13) textColor:COLOR1515];
            xuhao.mySize = kAutoSize;
            [contentLay addSubview:xuhao];
            
            QMUIButton * titleBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
            [titleBtn setImage:UIImageMake(@"monitor_jiantou") forState:UIControlStateNormal];
            titleBtn.mySize = kAutoSize;
            [titleBtn setTitle:contentArr[i] forState:UIControlStateNormal];
            [titleBtn setTitleColor:COLOR1515 forState:UIControlStateNormal];
            titleBtn.titleLabel.font = UIFontMake(13);
            titleBtn.imagePosition = QMUIButtonImagePositionRight;
            titleBtn.spacingBetweenImageAndTitle = 5;
            titleBtn.myLeft = 10;
            [titleBtn addTarget:self action:@selector(titleBtnClick) forControlEvents:UIControlEventTouchUpInside];
            [contentLay addSubview:titleBtn];
            
            UIView *view = UIView.new;
            view.weight = 1;
            [contentLay addSubview:view];
            
            UILabel *firstNum = [UILabel createLabelText:@"2" font:UIFontMake(12) textColor:COLOR_4];
            firstNum.mySize = CGSizeMake(20, 20);
            firstNum.backgroundColor = HexColor(@"#FF5B35");
            ViewCorner(firstNum, 10);
            firstNum.textAlignment = NSTextAlignmentCenter;
            [contentLay addSubview:firstNum];
            
            UILabel *secNum = [UILabel createLabelText:@"2" font:UIFontMake(12) textColor:COLOR_4];
            secNum.mySize = CGSizeMake(20, 20);
            secNum.backgroundColor = HexColor(@"#FF5B35");
            ViewCorner(secNum, 10);
            secNum.textAlignment = NSTextAlignmentCenter;
            [contentLay addSubview:secNum];
            
            UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"monitor_jiang")];
            imageView.mySize = CGSizeMake(24, 24);
            [contentLay addSubview:imageView];
        }
    }
    
    MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    bottom.myHorzMargin = 0;
    bottom.padding = UIEdgeInsetsMake(10, 15, 10, 15);
    bottom.backgroundColor = COLOR_4;
    bottom.layer.cornerRadius = 10;
    bottom.subviewHSpace = 15;
    bottom.myHeight = 52;
    bottom.gravity = MyGravity_Vert_Center;
    [root addSubview:bottom];
    [bottom setTarget:self action:@selector(bottomClick)];
    
    {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"monitor_qushi")];
        imageView.mySize = CGSizeMake(24, 24);
        [bottom addSubview:imageView];
        
        UILabel *name = [UILabel createLabelText:@"历史检测趋势图" font:UIFontMake(15) textColor:COLOR1515];
        name.myHeight = kAutoHeight;
        name.weight = 1;
        [bottom addSubview:name];
        
        UIImageView *right = [[UIImageView alloc]initWithImage:UIImageMake(@"icon_arrow_right")];
        right.mySize = CGSizeMake(16, 16);
        [bottom addSubview:right];
    }
    
    
}

- (void)titleBtnClick {
    OrganDetailInfoViewController *vc = OrganDetailInfoViewController.new;
    [self showViewController:vc sender:self];
    
}

- (void)bottomClick {
    OrganChartViewController *vc  = OrganChartViewController.new;
    [self showViewController:vc sender:self];
}
@end
